<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>MySQL性能优化之Linux系统参数优化 | Ahuang'Blog</title><meta name="author" content="Ahuang"><meta name="copyright" content="Ahuang"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="一些对数据库影响较大的参数配置来优化数据库性能">
<meta property="og:type" content="article">
<meta property="og:title" content="MySQL性能优化之Linux系统参数优化">
<meta property="og:url" content="http://huangxiaochang.gitee.io/ahuang_blog/2021/08/05/032/index.html">
<meta property="og:site_name" content="Ahuang&#39;Blog">
<meta property="og:description" content="一些对数据库影响较大的参数配置来优化数据库性能">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png">
<meta property="article:published_time" content="2021-08-05T11:21:19.000Z">
<meta property="article:modified_time" content="2023-02-02T05:47:13.329Z">
<meta property="article:author" content="Ahuang">
<meta property="article:tag" content="MySQL">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png"><link rel="shortcut icon" href="/ahuang_blog/img/favicon.ico"><link rel="canonical" href="http://huangxiaochang.gitee.io/ahuang_blog/2021/08/05/032/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta/><link rel="stylesheet" href="/ahuang_blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/ahuang_blog/',
  algolia: undefined,
  localSearch: {"path":"/ahuang_blog/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: {"limitDay":500,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":400},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'MySQL性能优化之Linux系统参数优化',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-02-02 13:47:13'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = url => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      link.onload = () => resolve()
      link.onerror = () => reject()
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/blog/css/transpancy.css"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/js-heo@1.0.11/mainColor/heoMainColor.css"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/js-heo@1.0.11/categoryBar/categoryBar.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-clock/lib/clock.min.css" /><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (false) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/ahuang_blog/img/Misaka.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/ahuang_blog/archives/"><div class="headline">文章</div><div class="length-num">51</div></a><a href="/ahuang_blog/tags/"><div class="headline">标签</div><div class="length-num">35</div></a><a href="/ahuang_blog/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/ahuang_blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg fixed" id="page-header" style="background-image: url('https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png')"><nav id="nav"><span id="blog-info"><a href="/ahuang_blog/" title="Ahuang'Blog"><span class="site-name">Ahuang'Blog</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/ahuang_blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/ahuang_blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">MySQL性能优化之Linux系统参数优化</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-08-05T11:21:19.000Z" title="发表于 2021-08-05 19:21:19">2021-08-05</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-02-02T05:47:13.329Z" title="更新于 2023-02-02 13:47:13">2023-02-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/ahuang_blog/categories/MySQL/">MySQL</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="MySQL性能优化之Linux系统参数优化"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>以常用的CentOs为例，改变一些对数据库影响较大的参数配置来优化数据库性能</p>
<h2 id="内核相关的参数配置"><a href="#内核相关的参数配置" class="headerlink" title="内核相关的参数配置"></a>内核相关的参数配置</h2><h3 id="网络相关参数"><a href="#网络相关参数" class="headerlink" title="网络相关参数"></a>网络相关参数</h3><p>说起网络，首次先来了解一下tcp链接，对于tcp链接来说服务器与客户端需要三次握手来建立网络的链接，当三次握手成功之后，端口由监听转换成了可连接，然 后这条链路就可以传输数据了，对于一个监听的端口都会有自己的监听队列。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">net.core.somaxconn = 65535   </span><br><span class="line">net.core.netdev_max_backlog = 65535</span><br><span class="line">net.ipv4.tcp_max_syn_backlog = 65535</span><br></pre></td></tr></table></figure>
<p>配置1 ：每个端口监听队列的最大长度，作用：默认值比较小，对于负载大的时候需要修改更大的值<br>配置2：在每个网络接口接收数据包的速率比内核处理数据包的速率快的时候允许未发送到队列的数据包最大的数目<br>配置3：还未获得对方链接的请求和保存在列队中的最大数目，作用：对超过这些数值的链接会被抛弃，所以要调大一些</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">net.core.wmem_default = 87380</span><br><span class="line">net.core.wmem_max = 16777216</span><br><span class="line">net.core.rmem_default = 87380</span><br><span class="line">net.core.rmem_max = 16777216</span><br></pre></td></tr></table></figure>
<p>配置1、配置2：用于控制tcp链接处理的等待状态的时间，对于链接比较频繁的系统，通常会有大量的链接处于等待状态的，较少这种等待的时间，加快tcp的回收速度<br>配置3、配置4：用于加快tcp链接的回收，在高负载的情况下是非常重要的，如果有大量的数据库链接请求，如果tcp链接呗占满的话，就会出现数据库无法链接的现象。<br>因此以上四个参数决定了tcp接连接收和发送缓冲区的默认值和最大值，对于数据库应用来说，也需要吧这几个值调的稍微大一点</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">net.ipv4.tcp_keepalive_time = 120   </span><br><span class="line">net.ipv4.tcp_keepalive_intvl = 30  </span><br><span class="line">net.ipv4.tcp_keepalive_probes = 3 </span><br></pre></td></tr></table></figure>
<p>配置1：tcp发送探测消息时间的间隔<br>配置2：tcp未获得响应时，重发该消息时间的间隔<br>配置3：在tcp链接失效之前，最多发送多少个探测消息<br>用于减少失效链接所占用的tcp系统资源的数量,加快资源回收的效率。 以上三个值的意思就是如果一个tcp链接120秒中没有数据传输则开始探测有效性，每次探测的时间间隔是30秒，最多探测3次</p>
<h3 id="内存的相关参数"><a href="#内存的相关参数" class="headerlink" title="内存的相关参数"></a>内存的相关参数</h3><p>用于定义单个共享内存段的最大值</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kernel.shmmax = 4294967295</span><br></pre></td></tr></table></figure>
<p>这个参数应该设置的足够大，以便于在一个共享内存段下容纳下整个的Innodb缓冲池的大小<br>这个值的大小对于64位的Linux系统，可取的最大值为物理内存值-1byte，建议值大于物理内存的一半，一般取值大于Innodb缓冲池的大小即可，可以取值物理内存-1byte.</p>
<p>当内存不足时会对性能产生比较明显的影响</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vm.swappiness = 0 </span><br></pre></td></tr></table></figure>
<p>在mysql服务器上保留交换区很有必要的，但是要控制何时使用交换分区，<br>vm.sawppiness &#x3D;0就是告诉linux内核除非内存完全满了，否则不要使用交换区。(Linux系统内存交换区：在linux系统安装时都会有一个特殊的磁盘分区，称之为系统交 换分区 swap就是交换分区 ，当操作系统因为没有足够的内存时就会将一些虚拟内存写到磁盘的交换区中这样就会发生内存交换。)</p>
<h2 id="增加资源文件限制（etc-x2F-security-x2F-limit-conf）"><a href="#增加资源文件限制（etc-x2F-security-x2F-limit-conf）" class="headerlink" title="增加资源文件限制（etc&#x2F;security&#x2F;limit.conf）"></a>增加资源文件限制（etc&#x2F;security&#x2F;limit.conf）</h2><p>这个文件是linux PAM也就是插入式认证模块配置文件，即打开文件数的限制</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">*soft nofile 65535</span><br><span class="line">*hard nofile 65535 </span><br></pre></td></tr></table></figure>
<p>以上两个配置是用于控制打开文件的数量的限制<br>表示对所有用户有效 soft 指的是当前系统生效的设置 对与同一资源 soft设置不能比hard高 hard 表明系统中所能设定的最大值 nofile 表示所限制的资源是打开文件的最大数目 65535 就是限制的数量<br>可打开的文件数量增加到了65535个以保证可以打开足够多的文件句柄 <mark class="hl-label red">注意：这个文件的修改需要重启系统才能生效</mark> </p>
<h2 id="磁盘调整策略（sys-x2F-block-x2F-decname-x2F-queue-x2F-scheuler）"><a href="#磁盘调整策略（sys-x2F-block-x2F-decname-x2F-queue-x2F-scheuler）" class="headerlink" title="磁盘调整策略（sys&#x2F;block&#x2F;decname&#x2F;queue&#x2F;scheuler）"></a>磁盘调整策略（sys&#x2F;block&#x2F;decname&#x2F;queue&#x2F;scheuler）</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span>  /sys/block/sda/queue/scheduler //查看磁盘调度策略命令</span><br><span class="line">noop anticipatory deadline [cfq]   //磁盘调整策略位cfq</span><br><span class="line"><span class="built_in">echo</span> deadline &gt; /sys/block/sda/queue/scheduler  //改变磁盘调整策略命令</span><br></pre></td></tr></table></figure>
<p>noop（电梯式调度策略）: noop实现了一个FIFO列队，它像电梯的工作方法一样对I&#x2F;O请求进行组织，当有一个新的请求到来时，它将请求合并到最近的请求之后，以此来保证请求同一介质。NOOP倾向饿死读而利于写，因此NOOP对于闪存设备、RAM及嵌入式系统是最好的选择。<br>deadline (截止时间调度策略): 确保了在一个截止时间内服务请求，这个截止时间是可调整的，而默认读期限短于写期限。这样就防止了写操作因为不能被读取而饿死的现象，Deadline对数据库类应用是最好的选择。<br>anticipatory(预料I&#x2F;O调整策略) :本质上与Deadline一样，但是最后一次读操作，要等待6ms，才能继续对其他I&#x2F;O请求进行调度。它会在每个6ms中插入新的I&#x2F;O操作，而会将一些小写入流合并成一个大写入流，用写入延时换取量大的写入吞吐 量。AS适合于写入较多的环境，比如文件服务器，AS对数据库环境表现很差。</p>
<p>以上是系统配置设置来优化数据库的</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://huangxiaochang.gitee.io/ahuang_blog">Ahuang</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://huangxiaochang.gitee.io/ahuang_blog/2021/08/05/032/">http://huangxiaochang.gitee.io/ahuang_blog/2021/08/05/032/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://huangxiaochang.gitee.io/ahuang_blog" target="_blank">Ahuang'Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/ahuang_blog/tags/MySQL/">MySQL</a><a class="post-meta__tags" href="/ahuang_blog/tags/Linux/">Linux</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/ahuang_blog/2021/08/09/033/" title="MySQL性能优化之Linux文件系统参数优化"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" onerror="onerror=null;src='/ahuang_blog/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">MySQL性能优化之Linux文件系统参数优化</div></div></a></div><div class="next-post pull-right"><a href="/ahuang_blog/2021/06/29/031/" title="Php设计模式之适配器模式"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" onerror="onerror=null;src='/ahuang_blog/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Php设计模式之适配器模式</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/ahuang_blog/2021/08/09/033/" title="MySQL性能优化之Linux文件系统参数优化"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-09</div><div class="title">MySQL性能优化之Linux文件系统参数优化</div></div></a></div><div><a href="/ahuang_blog/2021/08/12/034/" title="MySQL的二进制日志"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-12</div><div class="title">MySQL的二进制日志</div></div></a></div><div><a href="/ahuang_blog/2021/08/13/035/" title="MySQL主从复制(日志复制)"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-13</div><div class="title">MySQL主从复制(日志复制)</div></div></a></div><div><a href="/ahuang_blog/2021/08/15/036/" title="MySQL主从复制(GTID复制)【推荐】"><img class="cover" src="https://fastly.jsdelivr.net/gh/jerryc127/CDN@latest/cover/default_bg.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-15</div><div class="title">MySQL主从复制(GTID复制)【推荐】</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/ahuang_blog/img/Misaka.jpg" onerror="this.onerror=null;this.src='/ahuang_blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Ahuang</div><div class="author-info__description">Everything can be expected in the future</div></div><div class="card-info-data site-data is-center"><a href="/ahuang_blog/archives/"><div class="headline">文章</div><div class="length-num">51</div></a><a href="/ahuang_blog/tags/"><div class="headline">标签</div><div class="length-num">35</div></a><a href="/ahuang_blog/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/changad" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:136081905@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">快乐每一天！！！</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%86%85%E6%A0%B8%E7%9B%B8%E5%85%B3%E7%9A%84%E5%8F%82%E6%95%B0%E9%85%8D%E7%BD%AE"><span class="toc-number">1.</span> <span class="toc-text">内核相关的参数配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E7%9B%B8%E5%85%B3%E5%8F%82%E6%95%B0"><span class="toc-number">1.1.</span> <span class="toc-text">网络相关参数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%86%85%E5%AD%98%E7%9A%84%E7%9B%B8%E5%85%B3%E5%8F%82%E6%95%B0"><span class="toc-number">1.2.</span> <span class="toc-text">内存的相关参数</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A2%9E%E5%8A%A0%E8%B5%84%E6%BA%90%E6%96%87%E4%BB%B6%E9%99%90%E5%88%B6%EF%BC%88etc-x2F-security-x2F-limit-conf%EF%BC%89"><span class="toc-number">2.</span> <span class="toc-text">增加资源文件限制（etc&#x2F;security&#x2F;limit.conf）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%A3%81%E7%9B%98%E8%B0%83%E6%95%B4%E7%AD%96%E7%95%A5%EF%BC%88sys-x2F-block-x2F-decname-x2F-queue-x2F-scheuler%EF%BC%89"><span class="toc-number">3.</span> <span class="toc-text">磁盘调整策略（sys&#x2F;block&#x2F;decname&#x2F;queue&#x2F;scheuler）</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/ahuang_blog/2022/04/24/051/" title="项目中一些ThinkPhp的使用小技巧">项目中一些ThinkPhp的使用小技巧</a><time datetime="2022-04-24T10:43:22.000Z" title="发表于 2022-04-24 18:43:22">2022-04-24</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/ahuang_blog/2022/04/08/050/" title="Sql查询排名">Sql查询排名</a><time datetime="2022-04-08T08:24:16.000Z" title="发表于 2022-04-08 16:24:16">2022-04-08</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/ahuang_blog/2022/03/06/049/" title="ThinkPhp的跨域问题">ThinkPhp的跨域问题</a><time datetime="2022-03-06T04:40:38.000Z" title="发表于 2022-03-06 12:40:38">2022-03-06</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/ahuang_blog/2021/11/13/048/" title="Nginx关于Socket的配置">Nginx关于Socket的配置</a><time datetime="2021-11-13T07:02:15.000Z" title="发表于 2021-11-13 15:02:15">2021-11-13</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/ahuang_blog/2021/10/28/047/" title="Node.js之Express关于socket.io的使用">Node.js之Express关于socket.io的使用</a><time datetime="2021-10-28T04:36:17.000Z" title="发表于 2021-10-28 12:36:17">2021-10-28</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2018 - 2023 By Ahuang</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Everything can be expected in the future!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/ahuang_blog/js/utils.js"></script><script src="/ahuang_blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="/ahuang_blog/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script><script async src="https://cdn.jsdelivr.net/npm/js-heo@1.0.11/categoryBar/categoryBar.js"></script><script src="/blog/js/categoryBar.js"><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="true"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_clock_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src="/ahuang_blog/img/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_injector_config();
  }
  </script><script src="https://pv.sohu.com/cityjson?ie=utf-8"></script><script data-pjax src="https://npm.elemecdn.com/hexo-butterfly-clock/lib/clock.min.js"></script><!-- hexo injector body_end end --></body></html>